/*
 * @Description:
 * @Date: 2023-04-04 10:10:39
 * @LastEditors: czp
 * @LastEditTime: 2023-05-09 11:04:30
 */
import { ISignInForm } from "@/components/ToolRight/components/SignIn.vue";
import { ISignUpForm } from "@/components/ToolRight/components/SignUp.vue";
import axios from "@/utils/axios";
import { IUserInfo } from "../interface/user";
import { IAuthentication } from "@/views/user/components/Identity.vue";
import { IEditPassword } from "@/views/user/components/Information/components/EditPassword.vue";
import { IResetPsdForm } from "@/components/ToolRight/components/ResetPsd.vue";
/**
 * 注册
 */
export const userSignUp = (options: Omit<ISignUpForm, "isAgree">) => {
	return axios.request<null>({
		url: "api/front/register/register",
		method: "POST",
		data: options
	});
};
/**
 * 登录
 */
export const userSignIn = (options: ISignInForm) => {
	return axios.request<{ token: string }>({
		url: "api/front/login/login",
		method: "POST",
		data: options
	});
};
/**
 * 忘记密码
 */
export const userResetPsd = (options: IResetPsdForm) => {
	return axios.request({
		url: "api/front/login/forgotPassword",
		method: "POST",
		data: options
	});
};

/**
 * 获取个人信息
 * @param options
 * @returns
 */
export const userGetUserInfo = () => {
	return axios.request<IUserInfo>({
		url: "api/front/user/getPersonal",
		method: "POST"
	});
};

/**
 * 修改基本资料
 */
export const userUpdateBaseInfo = (options: Partial<IUserInfo>) => {
	return axios.request<null>({
		url: "api/front/user/update",
		method: "POST",
		data: options
	});
};

/**
 * 修改密码
 * @param options
 * @returns
 */
export const userModifyPassword = (options: IEditPassword) => {
	return axios.request<null>({
		url: "api/front/user/updatePassword",
		method: "POST",
		data: options
	});
};

/**
 * 实名认证
 * @param options
 * @returns
 */
export const userPostIdentity = (options: IAuthentication) => {
	return axios.request<null>({
		url: "api/front/user/realNameAuthentication",
		method: "POST",
		data: options
	});
};

/**
 * 上报观看视频
 * @param options
 * @returns
 */
export const userSubmitWatchVideo = (options: { videoId: number }) => {
	return axios.request<null>({
		url: "api/front/watchVideo/create",
		method: "POST",
		data: options
	});
};
